home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / a_to_d / bildemo / bildemo1.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  4.0 KB  |  123 lines

  1. unit Bildemo1;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, BIL, DdeMan;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     ButtonInstall: TButton;
  12.     ButtonExit: TButton;
  13.     EditInstallTo: TEdit;
  14.     EditInstallFrom: TEdit;
  15.     Label1: TLabel;
  16.     Label2: TLabel;
  17.     DdeClientConv1: TDdeClientConv;
  18.     procedure ButtonInstallClick(Sender: TObject);
  19.     procedure ButtonExitClick(Sender: TObject);
  20.     procedure FormCreate(Sender: TObject);
  21.   private
  22.     { Private declarations }
  23.   public
  24.     { Public declarations }
  25.   end;
  26.  
  27. var
  28.   Form1: TForm1;
  29.  
  30. implementation
  31.  
  32. {$R *.DFM}
  33.  
  34. procedure TForm1.ButtonInstallClick(Sender: TObject);
  35. Var
  36.    TListParams: TStringList;
  37.    sProgram: String;
  38.    bRet:     boolean;
  39.    cIDAPI:   string;
  40. begin
  41.  
  42.     { Set directory to a directory supplied in a Edit Box }
  43.     SetInstallToDir( EditInstallTo.Text );
  44.  
  45.     { Set directory to a directory supplied in a Edit Box }
  46.     SetInstallFromDir( EditInstallFrom.Text );
  47.  
  48.     { Get Program Directory }
  49.     sProgram := sGetProgDir;
  50.  
  51.     if MessageDlg( 'This Program is about to do the following:' + chr(13) + chr(10) +
  52.                 '  Create directory ' + sProgram + chr(13) + chr(10) +
  53.                 '  Decompress ' + EditInstallFrom.Text + '\DEMO.TX_' + chr(13) + chr(10) +
  54.                 '     to ' + sProgram + '\DEMO.TXT' + chr(13) + chr(10) +
  55.                 '  Add an Alias to your IDAPI.CFG ' + chr(13) + chr(10) +
  56.                 '  Create/Modify ' + sProgram + '\BILDEMO.INI' + chr(13) + chr(10) +
  57.                 '  Create Program Group and Item'
  58.                 ,mtInformation, [mbOk,mbCancel],0 ) = mrOK then
  59.     begin
  60.  
  61.        if MessageDlg( 'Warning: This Program is about to Edit your IDAPI.INI' + chr(13) + chr(10) +
  62.                       '         If you have not backed up this file' + chr(13) + chr(10) +
  63.                       '         cancel now and back it up'
  64.                       ,mtInformation, [mbOk,mbCancel],0 ) = mrOK then
  65.        begin               
  66.  
  67.          { Create Program directory }
  68.          bRet := bCreateDirectory( sProgram );
  69.  
  70.          { Decompress DEMO.TX_ to DEMO.TXT in the program directory }
  71.          bRet := bInstallFile('DEMO.TX_', 'DEMO.TXT', fiSameDateTimeIgnore, 'P' );
  72.  
  73.          { Backup IDAIP.CFG }
  74.          cIDAPI := sReadProfile( sGetWinDir + '\WIN.INI',
  75.                                  'IDAPI', 'CONFIGFILE01', '');
  76.          sBackUpByNumber( cIDAPI );
  77.  
  78.          if length( cIDAPI ) > 1 then
  79.             begin
  80.             { Create a Alias for Interbase }
  81.             TListParams:= TStringList.create;
  82.             TListParams.Add( 'DB INFO');
  83.             TListParams.Add( 'TYPE=INTRBASE' );
  84.             TListParams.Add( 'PATH=' );
  85.             TListParams.Add( 'DB OPEN' );
  86.             TListParams.Add( 'USER NAME=' );
  87.             TListParams.Add( 'ODBC DSN=' );
  88.             TListParams.Add( 'OPEN MODE=READ/WRITE' );
  89.             TListParams.Add( 'SCHEMA CACHE SIZE=8' );
  90.             TListParams.Add( 'SQLQRYMODE=' );
  91.             TListParams.Add( 'LANGDRIVER=' );
  92.             TListParams.Add( 'SQLPASSTHRU MODE=' );
  93.             bRet := bBDEAddAlias('BILDEMO',TListParams);
  94.             TListParams.Clear;
  95.             end;
  96.          { Create/Update BILDEMO.INI }
  97.          bRet := bWriteProfile( sProgram+'\BILDEMO.INI', 'BILGROUP','BILITEM','VALUE');
  98.  
  99.          { Create the program Group/Item
  100.           The first parameter is a TDdeClientConv this is create by 
  101.           clicking on the System tab on the visual controls,
  102.           then clicking on the DdeClientConv }
  103.          bRet := bAdd2ProgMan( DdeClientConv1, 'BILDemo', 'BILDEMO Executable', EditInstallFrom.Text + '\BILDEMO.EXE');
  104.       end;
  105.    end;
  106. end;
  107. procedure TForm1.ButtonExitClick(Sender: TObject);
  108. begin
  109.      Halt;
  110. end;
  111.  
  112. procedure TForm1.FormCreate(Sender: TObject);
  113. var
  114.    sPath: string;
  115. begin
  116.     sPath := sGetPath(Application.ExeName);
  117.     EditInstallTo.Text := sPath + '\TO';
  118.     EditInstallFrom.Text := sPath;
  119.  
  120. end;
  121.  
  122. end.
  123.